<?php
/**
 * This file is form http://findcat.cn
 *
 * @link     https://findcat.cn
 * @email    1476982312@qq.com
 */
namespace App\Observers;

use App\Models\Website;
use Illuminate\Support\Facades\Cache;

class WebsiteObserver
{
    /**
     * 网站公告模型事件.
     */
    public function saved()
    {
        Cache::forget('web_site');

        $webSite = Website::query()
            ->where('status', true)
            ->orderBy('sort', 'asc')
            ->get();

        Cache::forever('web_site', $webSite);
    }

    /**
     * 网站公告删除事件.
     */
    public function deleted()
    {
        Cache::forget('web_site');

        $webSite = Website::query()
            ->where('status', true)
            ->orderBy('sort', 'asc')
            ->get();

        Cache::forever('web_site', $webSite);
    }
}
